package com.ming.interview;

import java.util.Scanner;

/**
 * @Description 打印菱形
 * @Author ye.ming
 * @Date Created in 2019/8/26
 */
public class Main17 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要打印的菱形边长：");
        int n = sc.nextInt();
        if (n < 1) {
            return;
        }
        int row = 2 * n - 1;
        for (int i = 0; i < row; i++) {
            if (i < n) {
                m1(" ", n - 1 - i);
                m1("*", i * 2 + 1);
            } else {
                m1(" ", i - n + 1);
                m1("*", (row - i) * 2 -1);
            }
            System.out.println();
        }


    }

    private static void m1(String c, int n) {
        for (int i = 0; i < n; i++) {
            System.out.print(c);
        }
    }


}
